﻿<?php
	class mysqls
	{
		private $server_address = "localhost";
		private $server_username = "root";
		private $server_pwd = "";
		private $conn;
		public function __construct($dbname)
		{
			$this->con = mysql_connect($this->server_address,$this->server_username,$this->server_pwd,$newLink = NULL);
			mysql_select_db($dbname,$this->con);
		}

		public function dbquery($sql){
			$row = mysql_query($sql,$this->con);
			return $row;
		}

		public function dbfetchAll($sql){
			$arr = array();
            $row = $this->dbquery($sql);
			if(!empty($row)){			
				while ($result = mysql_fetch_array($row)) {
					$arr[] = $result;
				}
			}else{
				$arr = array();
			}
			return $arr;
		}

		public function dbGetRow($sql){
			$row = $this->dbquery($sql);
			$result = mysql_fetch_array($row);
			return $result;
		}
	}


	/**
	* 
	*/
	class verify
	{
		private $user;
		private $pwd;
		function __construct($user_name,$user_pwd)
		{
			$this->user = $user_name;
			$this->pwd = $user_pwd;
		}
		public function verifyUser(){
			$arr = array(
				'laopo' => '520juan',
				'guanguan' => 'laoguan11',
			 );
			
			foreach ($arr as $key => $value) {
				if($key == $this->user && $value == $this->pwd){
					$_SESSION['user_name'] = $this->user;
				}
			}
		}
	}
	// $db = new mysqls("magento");
	// $sql = "select * from tbx_catalog_product_entity_int";
	// $row = $db->dbfetchAll($sql);
	// print_r($row);

	// $v = new verify('laopo','520juan');
	// $v->verifyUser();
	// if(empty($_SESSION['user_name'])){
	// 	echo "empty";
	// }else{
	// 	echo "right";
	// }

?>